import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

import { AuthService } from '../auth/auth.service';
import { User } from '../auth/user.model';
import { UntreatedMessagesNumberService } from '../untreated-messages/untreated-messages-number.service';

@Component({
  moduleId: module.id,
  selector: 'app-layout-header',
  templateUrl: './layout-header.component.html',
  styleUrls: ['./layout-header.component.scss']
})
export class LayoutHeaderComponent implements OnInit {
  constructor(
    private auth: AuthService,
    private untreatedMessagesNumber:UntreatedMessagesNumberService,
    private router:Router
  ) { }

  ngOnInit() {
    this.untreatedMessagesNumber.getNumber();
  }

  signOut () {
    this.auth.signOut().subscribe(() => {
      this.router.navigateByUrl('/auth/sign-in');
    });
  }

}
